home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2b.lha / p4-1.2b / alog / alog.h < prev    next >
C/C++ Source or Header  |  1993-02-06  |  4KB  |  168 lines

  1. #include <stdio.h>
  2. #include "usc.h"
  3.  
  4. #define MAX_DIRNAME_LEN     100
  5. #define MAX_LOG_STRING_LEN     12
  6. #define MAX_BUF_SIZE           50
  7. #define ALOG_LOGFILE        "alogfile.p"
  8.  
  9. #define ALOG_TRUNCATE        0
  10. #define ALOG_WRAP        1
  11.  
  12. #define ALOG_OFF        0
  13. #define ALOG_ON            1
  14.  
  15. #define ALOG_EVENT_SYNC        -101
  16. #define ALOG_EVENT_PAIR_A1     -102
  17. #define ALOG_EVENT_PAIR_A2     -103
  18. #define ALOG_EVENT_PAIR_B1     -104
  19.  
  20.  
  21. struct head_trace_buf {
  22.         int             next_entry;
  23.         int             max_size;
  24.         unsigned long   prev_time;
  25.         unsigned long   ind_time;
  26.         int             trace_flag;
  27.         struct trace_buf *xx_list;
  28.         struct trace_buf *cbuf;
  29.         FILE            *file_t;
  30. };
  31.  
  32. struct trace_buf {
  33.         struct trace_buf *next_buf;
  34.         struct trace_table {
  35.                 int     id;
  36.                 int     task_id;
  37.                 int     event;
  38.                 int     data_int;
  39.                 char    data_string[MAX_LOG_STRING_LEN+1];
  40.                 unsigned long     tind;
  41.                 unsigned long     tstamp;
  42.         } ALOG_table[MAX_BUF_SIZE];
  43. };
  44.  
  45. extern int xx_alog_status;
  46. extern int xx_alog_setup_called;
  47. extern int xx_alog_output_called;
  48. extern char xx_alog_outdir[];
  49. extern struct head_trace_buf *xx_buf_head;
  50.  
  51. /* 
  52.  * Function declarations 
  53.  */
  54.  
  55. VOID xx_write(), xx_dump(), xx_dump_aux(),
  56.      xx_user(), xx_user1(), xx_alog_setup();
  57. int  xx_getbuf();
  58.  
  59.  
  60. #ifdef ALOG_TRACE
  61.  
  62. #define ALOG_DEC
  63.  
  64. #define ALOG_STATUS(status) \
  65.     if ((status) == ALOG_ON) \
  66.         xx_alog_status |= 0x1; \
  67.     else \
  68.         xx_alog_status &= ~0x1
  69.  
  70. #define ALOG_ENABLE ALOG_STATUS(ALOG_ON)
  71.  
  72. #define ALOG_DISABLE ALOG_STATUS(ALOG_OFF)
  73.  
  74. #define ALOG_SETDIR(dir) \
  75.     {\
  76.     strncpy(xx_alog_outdir,(dir),MAX_DIRNAME_LEN); \
  77.     xx_alog_outdir[MAX_DIRNAME_LEN] = '\0'; \
  78.     }
  79.  
  80.  
  81. #define ALOG_SETUP(pid,flag) \
  82.         {\
  83.             if (xx_alog_status & 0x1 &&  !xx_alog_setup_called) \
  84.         {\
  85.                 xx_alog_setup_called = 1;\
  86.                 xx_alog_setup((pid),(flag));\
  87.         }\
  88.         }
  89.  
  90. #define ALOG_MASTER(pid,flag) \
  91.     {\
  92.         if (xx_alog_status & 0x1) \
  93.         {\
  94.             xx_alog_setup((pid),(flag)); \
  95.             xx_user1(xx_buf_head,(pid)); \
  96.         }\
  97.     }
  98.  
  99. #define ALOG_DEFINE(event,edef,strdef) \
  100.         {\
  101.         if (xx_alog_status & 0x1) \
  102.         {\
  103.             xx_write(xx_buf_head,0,(-9),(event),(edef)); \
  104.             xx_write(xx_buf_head,0,(-10),(event),(strdef)); \
  105.         }\
  106.         }
  107.  
  108. #define ALOG_LOG(pid,type,data1,data2) \
  109.     {\
  110.     if (xx_alog_status & 0x1) \
  111.         xx_write(xx_buf_head,(pid),(type),(data1),(data2)); \
  112.     }
  113.  
  114. #define ALOG_OUTPUT \
  115.         {\
  116.             if (xx_alog_status & 0x1  &&  !xx_alog_output_called) \
  117.         {\
  118.                 xx_alog_output_called = 1;\
  119.                 xx_dump(xx_buf_head);\
  120.         }\
  121.         }
  122.  
  123. #else
  124.  
  125. #define ALOG_DEC 
  126. #define ALOG_STATUS(a)
  127. #define ALOG_ENABLE
  128. #define ALOG_DISABLE
  129. #define ALOG_SETDIR(a)
  130. #define ALOG_SETUP(a,b)
  131. #define ALOG_MASTER(a,b)
  132. #define ALOG_DEFINE(a,b,c)
  133. #define ALOG_LOG(a,b,c,d)
  134. #define ALOG_OUTPUT
  135.  
  136. #endif
  137.  
  138. #if defined(IPSC860)      || defined(DELTA)        || \
  139.     defined(TITAN)        || defined(SYMMETRY_PTX) || \
  140.     defined(HP)           || defined(NCUBE)
  141. #define getwd(X)  getcwd(X)
  142. #endif
  143.  
  144. #if defined(CRAY) || defined(TITAN)  ||  defined(NCUBE)
  145. #define alogfm_ ALOGFM
  146. #define alogfs_ ALOGFS
  147. #define alogfd_ ALOGFD
  148. #define alogfl_ ALOGFL
  149. #define alogfo_ ALOGFO
  150. #define alogft_ ALOGFT
  151. #define alogfr_ ALOGFR
  152. #define alogf0_ ALOGF0
  153. #define alogf1_ ALOGF1
  154. #endif
  155.  
  156. #if defined(NEXT)
  157. #define alogfm_ alogfm
  158. #define alogfs_ alogfs
  159. #define alogfd_ alogfd
  160. #define alogfl_ alogfl
  161. #define alogfo_ alogfo
  162. #define alogft_ alogft
  163. #define alogfr_ alogfr
  164. #define alogf0_ alogf0
  165. #define alogf1_ alogf1
  166. #endif
  167.  
  168.